﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using LevenBlog.Core.Data;
using LevenBlog.Core.Entities;
using LevenBlog.Core.Cache;

namespace LevenBlog.Core.Service {
    public static class Config {
        private static readonly string cacheName = "levenblog_servicecache_config";

        public static lb_config Get(IDbProvider provider) {
            lb_config find = ObjectCache.Get<lb_config>(cacheName);
            if (find == null) {
                find = ProviderManager.Factory.Config.Get(provider);
                ObjectCache.Insert(cacheName, find);
            }
            return find;
        }

        public static void Update(IDbProvider provider, lb_config config) {
            ProviderManager.Factory.Config.Update(provider, config);
            Remove();
        }

        public static void Remove() {
            ObjectCache.Remove(cacheName);
        }
    }
}
